﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data;

using PolePositionMobileUtilityLogic;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityEntity
{
    public class ESection : EBaseLookup
    {
        private EMap m_Map;
        public EMap Map
        {
            get
            {
                return m_Map;
            }
            set
            {
                m_Map = value;
            }
        }

        public ESection()
        :base()
        {
            m_TableCollumnId = "SectionId";
            m_TableName = "tb_Sections";
        }
        public ESection(int id, string name, EMap map)
        {
            Id = id;
            Name = name;
            m_Map = map;
        }

        public static ESection[] GetAll()
        {
            ESection[] arr = new ESection[36];
            for (int i = 0; i <= 35; i++)
            {
                arr[i] = new ESection(i+1,(i+1).ToString(), new EMap(Int32.MinValue,""));
            }
            return arr;
        }

        public static ESection[] GetByMap(int mapId)
        {
            DataTable _dt = LSection.SelectAllByMap(mapId);
            ESection[] arr = new ESection[_dt.Rows.Count];
            for (int i = 0; i < _dt.Rows.Count; i++)
            {
                arr[i] = new ESection(ConvertMobileHelper.ToInt32(_dt.Rows[i]["SectionId"]), ConvertMobileHelper.Tostring(_dt.Rows[i]["Section_Name"]), new EMap(ConvertMobileHelper.ToInt32(_dt.Rows[i]["MapFk"]), ConvertMobileHelper.Tostring(_dt.Rows[i]["Map_Name"])));
            }
            return arr;
        }


    }
}
